package org.particlethink.mapper.impl;

import org.particlethink.config.RequestConfig;
import org.particlethink.mapper.DictMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Repository;

import java.io.IOException;
import java.util.List;


@Repository
@ConditionalOnExpression("#{!'dev'.equals('${spring.profiles.active}')}")
public class DictMapperImpl implements DictMapper {

    @Autowired
    private RequestConfig requestConfig;

    private static final String proProjectManage = "pro_project_manage";


    private List<String> Dict(String token, String dictName) {
        try {
            return DictRequestHelper.Dict(requestConfig.getUrl(), token, dictName).getTypes();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public List<String> projectManages(String token) {
        return Dict(token, proProjectManage);
    }


}

